﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Domain.Models;

namespace JXT.PrimaryKey.Batman.Domain.UserSystem.Models
{
    /// <summary>
    /// 用户登录状态
    /// </summary>
    [Serializable]
    public class LoginStatus : ValueObjectBase<LoginStatus>
    {
        /// <summary>
        /// 用户Id
        /// </summary>
        public int UserId { get; set; }

        /// <summary>
        /// 令牌
        /// </summary>
        public string Token { get; set; }

        /// <summary>
        /// 登陆时间
        /// </summary>
        public DateTime LoginTime { get; set; }

        /// <summary>
        /// 登录Ip
        /// </summary>
        public string LoginIp { get; set; }

        /// <summary>
        /// 最后活动时间
        /// </summary>
        public DateTime LastActiveTime { get; set; }

        /// <summary>
        /// 最后活动Ip
        /// </summary>
        public string LastActiveIp { get; set; }

        /// <summary>
        /// OAuth配置Id
        /// </summary>
        public int OAuthId { get; set; }

        /// <summary>
        /// 第三方用户的token
        /// </summary>
        public string OAuthToken { get; set; }

        /// <summary>
        /// 第三方的用户token_secret
        /// </summary>
        public string OAuthTokenSecret { get; set; }

        /// <summary>
        /// 第三方的Verifier
        /// </summary>
        public string OAuthVerifier { get; set; }

        /// <summary>
        /// OAuth用户标识
        /// </summary>
        public string OAuthUserId { get; set; }

        /// <summary>
        /// 过期时间，默认为DateTime.MaxValue
        /// </summary>
        public DateTime Expires { get; set; }

        public LoginStatus()
        {
            Expires = DateTime.MaxValue;
        }

        public override bool Equals(LoginStatus other)
        {
            //throw new NotImplementedException();
            if (other == null)
                return false;
            return other.Expires == Expires &&
                other.LastActiveIp == LastActiveIp &&
                other.LastActiveTime == LastActiveTime &&
                other.LoginIp == LoginIp &&
                other.LoginTime == LoginTime &&
                other.Token == Token &&
                other.UserId == UserId;
        }
    }
}
